#!/bin/bash

ps -eo pid,user,cputime,%cpu,command |egrep -v -w "(' root '|rpc|rpcuser|mysql|ntp|smmsp|xfs|daemon|gdm|postfix|ganga|' argod '|' argored '|scp|paw|cc|gcc|f77|' swtest '|' maggiora '|' dirac ')" |awk -F' ' {'if (($3>"02:00:00") && ($4+0>"60"+0)) {system("kill -9 " $1); system("/usr/local/sbin/warn -u  " $2 " /usr/local/sbin/warn_message"); system("date"); print $1 " " $2 " " $3 " " $4 " " $5}'} >>/var/log/kill_process.log
ps -eo pid,user,cputime,%mem,command |egrep -v -w "(' root '|rpc|rpcuser|mysql|ntp|smmsp|xfs|daemon|gdm|postfix|ganga|' argod '|' argored '|scp|paw|cc|gcc|f77|' swtest '|' maggiora '|' dirac ')" |awk -F' ' {'if ( ($4+0>"20"+0)) {system("echo " $1); system("/usr/local/sbin/warn -u  " $2 " /usr/local/sbin/warn_message"); system("date"); print $1 " " $2 " " $3 " " $4 " " $5}'} >>/var/log/kill_process.log

